
import { useEffect, useState } from 'react'
import { useLocation, useNavigate } from 'react-router-dom'
import { Image, NavBar, Toast } from 'antd-mobile'
import userStore from '@/store/userStore'
import "./content.scss"
const Content = () => {
  const { index } = userStore();
  const location = useLocation()
  const { content, from } = location.state || {}
  const navigate = useNavigate()
  useEffect(() => {
    if (content === "" || content === undefined) {
      navigate(`${from}`)
    }
  }, [])
  const back = () => {
    navigate(`${from}`)
    // Toast.show({
    //   content: '点击了返回区域',
    //   duration: 1000,
    // })
  }
  return (
    <div className='container'>
      <NavBar style={{ height: '3rem', fontWeight: "600", borderBottom: '1px #eee solid', }}
        onBack={back}>{content.title}</NavBar>

      <p className="time">发布时间: {content.pub_date}</p>
      <div className='imgList'>
      {content.cover.images && content.cover.images.map(item => (
        <Image
        key={item}
          className='img'
          src={item}
          fit="cover"
        />
      ))
      }
      </div>
      <p className="content">{content.content}</p>
    </div>
  )
}
export default Content